<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="text">
  <script>
    const search = document.querySelector('input')
    search.addEventListener('input', async function () {
      const res = await fetch(`http://localhost:3000/new?author=${this.value}`)
        .then(res => res.json())
      console.log(res)
      if (res.length > 0) {
        const data = await fetch(`http://localhost:3000/comments?newsId=${res[0].id}`)
          .then(res => res.json())
        console.log(data)
      }
    })
  </script>
</body>

</html>